/*************************************************
Author: will
Date: 11/11/2013
Description:
Notes: 
*************************************************/

#ifndef __CChatMgr_h__
#define __CChatMgr_h__

#include "CTSizeString.h"
#include "CTArray.h"
#include "CTHashObjectMgr.h"
#include "commclass.h"

class CChatCheckMsg
{
public:
    CChatCheckMsg()
    {
        _uiGID = 0;
        _iSendMsgTime = 0;
    }

    unsigned int _uiGID;
    CTLib::CTSizeString<MAX_CHAT_MSG_CHECK_LEN + 1> _szCheckMsg;
    int _iSendMsgTime;
};

class CChatUser
{
public:
    CChatUser()
    {
        _iLastMatchTime = 0;
        _iMatchCount = 0;
    }

    int _iLastMatchTime; 
    int _iMatchCount;
};

class CChatMgr
{
public:
    CChatMgr();
    static int CountSize()
    {
        return CTLib::CTHashObjectMgr<unsigned int, CChatUser>::CountSize(MAX_REGISTER_PLAYER);
    }

    int Init(const char* sBuf)
    {
        return _stChatUserHash.Init(sBuf, MAX_REGISTER_PLAYER);
    }

    void AddMsg(unsigned int uiGID, CTLib::CTSizeString<200>& szMsg);
    bool IsAdMsg(unsigned int uiGID, CTLib::CTSizeString<200>& szMsg);

private:
    int _iNowIndex;
    CTLib::CTArray<CChatCheckMsg, MAX_CHAT_MSG_COUNT> _astCheckMsgs;
    CTLib::CTHashObjectMgr<unsigned int, CChatUser> _stChatUserHash;
};


#endif // __CChatMgr_h__

